#!/bin/sh
# Wrapper for benchmark.py. Locates Python install and 
# tells the user how to install it if it is missing.
extra_paths="/opt/local/bin:/usr/pkg/bin:/usr/local/bin:/usr/sfw/bin"
required_ver="24"
highest_ver='0'
os=`uname`
for dir in `echo echo $extra_paths $PATH | sed s/:/" "/g | xargs -n1 echo \
             | sort -u`
do
  python=""
  if [ -x "$dir/python2.5" ]; then
    python="$dir/python2.5"
  elif [ -x "$dir/python2.4" ]; then
    python="$dir/python2.4"
  elif [ -x "$dir/python" ]; then
    python="$dir/python"
  fi

  if [ "$python" != "" ]; then
    ver=`$python -V 2>&1 | cut -d" " -f2 | cut -d. -f1,2 | sed s/"\."/""/g`
    if [ $ver -gt $highest_ver ]; then
      if [ "$ver" -ge $required_ver ]; then
        use_python=$python
      fi
      highest_ver=$ver
    fi
  fi
done

if [ "$use_python" = "" ]; then
  if [ "$ver" != "" ]; then
    echo "Sorry, we could not find a new enough version of Python. Please install Python 2.4+"
  else
    echo "Sorry, we could not find a python interpreter. Please install Python 2.4+"
  fi
  
  case $os in
    FreeBSD)
      cmd="pkg_add -r python25"
    ;;
  esac
  exit
fi

$python ./benchmark.py $1 $2 $3 $4 $5 $6 $7 $8 $9
